import { Injectable } from '@angular/core';
import { NzModalService } from 'ng-zorro-antd/modal';
import { Observable } from 'rxjs';
import { IdentityRoleDto } from '../proxy/identity';
import { RefRoleDetailComponent } from './ref-role-detail.component';

@Injectable({
  providedIn: 'root',
})
export class RefRoleDetailService {
  private defaultTitle: '添加角色' | '编辑角色' = '添加角色';
  private defaultWidth: number = 600;
  constructor(private modalService: NzModalService) {}
  show(model?: IdentityRoleDto, options?: { title?: string; width?: number }): Observable<any> {
    var nzTitle = !options?.title ? this.defaultTitle : options.title;
    var nzWidth = !options?.width ? this.defaultWidth : options.width;
    let modalRef = this.modalService.create({
      nzTitle: nzTitle,
      nzMaskClosable: false,
      nzKeyboard: true,
      nzWidth: nzWidth,
      nzComponentParams: {
        model: !model ? null : model,
      },
      nzContent: RefRoleDetailComponent,
    });
    return modalRef.afterClose.asObservable();
  }
}
